#include <algorithm>
#include "stdafx.h"
#include "Inventory.h"

using namespace std;

class Inventory{

public:

	Inventory::Inventory ()
	{
    
	}

	Inventory::~Inventory ()
	{

	}


	/**
	 * Returns true if the inventory contains the passed in item.
	 */
	bool Inventory::Contains (const string& itemName)
	{
		for (vector<Item>::iterator it = (*contents).begin(); it != (*contents).end(); ++it)
		{
			if ((*(*it).GetName()) == itemName)
			{
				return true;
			}
		}

		return false;
	}

	/**
	 * Adds an item to the inventory.
	 */
	void Inventory::AddItem (const Item& item)
	{
		(*contents).push_back(item);
	}

	/**
	 * Removes an item from the inventory and returns a pointer to it. If the
	 * item isn't in the inventory, it returns NULL.
	 */
	Item* Inventory::TakeItem (const string& itemName)
	{
		int i = 0;
		for (vector<Item>::iterator it = (*contents).begin(); it != (*contents).end(); ++it, ++i)
		{
			if ((*(*it).GetName()) == itemName)
			{
				// If the vector is 5 larger than the number of items, shrink it down.
				if ((*contents).size + 5 < (*contents).capacity)
				{
					(*contents).shrink_to_fit;
				}

				// Remove item from inventory and return a pointer to it
				Item* result = &(*contents)[i];
				(*contents).erase((*contents).begin() + i);
				return result;
			}
		}

		return NULL;
	}

	bool operator==(const Item* other) const{

	}

	bool operator!=(const Item* other) const{

	}

private:

	string* name;
	string* description;

};